package cn.iocoder.yudao.module.member.dal.mysql.company;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.controller.admin.company.vo.CompanyPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.company.vo.CompanyRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.company.CompanyDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 企业 Mapper
 *
 * @author Alan
 */
@Mapper
public interface CompanyMapper extends BaseMapperX<CompanyDO> {

    default PageResult<CompanyDO> selectPage(CompanyPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CompanyDO>()
                .likeIfPresent(CompanyDO::getCompanyName, reqVO.getCompanyName())
                .eqIfPresent(CompanyDO::getLogoUrl, reqVO.getLogoUrl())
                .eqIfPresent(CompanyDO::getIndustry, reqVO.getIndustry())
                .eqIfPresent(CompanyDO::getCompanyNature, reqVO.getCompanyNature())
                .eqIfPresent(CompanyDO::getCompanyScale, reqVO.getCompanyScale())
                .eqIfPresent(CompanyDO::getCompanyWelfare, reqVO.getCompanyWelfare())
                .eqIfPresent(CompanyDO::getContacts, reqVO.getContacts())
                .eqIfPresent(CompanyDO::getPhone, reqVO.getPhone())
                .eqIfPresent(CompanyDO::getMail, reqVO.getMail())
                .eqIfPresent(CompanyDO::getProvinceId, reqVO.getProvinceId())
                .likeIfPresent(CompanyDO::getProvinceName, reqVO.getProvinceName())
                .eqIfPresent(CompanyDO::getCityId, reqVO.getCityId())
                .likeIfPresent(CompanyDO::getCityName, reqVO.getCityName())
                .eqIfPresent(CompanyDO::getDistrictId, reqVO.getDistrictId())
                .likeIfPresent(CompanyDO::getDistrictName, reqVO.getDistrictName())
                .eqIfPresent(CompanyDO::getAddress, reqVO.getAddress())
                .eqIfPresent(CompanyDO::getCompanyProfile, reqVO.getCompanyProfile())
                .eqIfPresent(CompanyDO::getSuperEmployer, reqVO.getSuperEmployer())
                .betweenIfPresent(CompanyDO::getHireTime, reqVO.getHireTime())
                .betweenIfPresent(CompanyDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CompanyDO::getId));
    }

    IPage<CompanyRespVO> getCompanyVoPage(@Param("page")Page<CompanyRespVO> page,@Param("vo")  CompanyPageReqVO pageReqVO);
}